<?php

use yii\helpers\Html;
use kartik\grid\GridView;
use common\models\business\BusinessContractStatements;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\business\models\BusinessContractStatementsSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '结算单管理';
$this->params['breadcrumbs'][] = $this->title;
?>


<section class="wrapper site-min-height">
    <!-- page start-->
    <section class="panel">
        <header class="panel-heading">
              <?= Html::a('返回','javascript:history.back(-1)'); ?>  <?= Html::encode($this->title) ?>
        </header>
        <div class="panel-body">
            <div class="adv-table editable-table ">
 


<div class="business-contract-statements-index">

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>


    <p>
        <?= Html::a('添加结算单', ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?php
    echo GridView::widget([
        'dataProvider'=>$dataProvider,
        'filterModel'=>$searchModel,
        'showPageSummary'=>true,
        'pjax'=>true,
        'striped'=>true,
        'hover'=>true,
        'panel'=>['type'=>'primary', 'heading'=>'结算单管理'],
        'containerOptions'=>['style'=>'overflow: auto'], // only set when $responsive = false
        'headerRowOptions'=>['class'=>'kartik-sheet-style'],
        'filterRowOptions'=>['class'=>'kartik-sheet-style'],
        'columns'=>[
            [
                'attribute'=>'id',
                'pageSummaryOptions'=>['class'=>'text-right text-warning'],
                'width'=>'100px',
            ],
            [
                'attribute'=>'number',
                'pageSummaryOptions'=>['class'=>'text-right text-warning'],
                'width'=>'100px',
            ],
            [
                'label' => '所属合同',
                'attribute'=>'contract.name',
                'width'=>'100px',
                'pageSummaryOptions'=>['class'=>'text-right text-warning'],
            ],
            [
                'attribute'=>'name',
                'pageSummaryOptions'=>['class'=>'text-right text-warning'],
                'width'=>'100px',
            ],
            [
                'attribute'=>'num',
                'pageSummaryOptions'=>['class'=>'text-right text-warning'],
                'width'=>'100px',
            ],
            [
                'attribute'=>'price',
                'pageSummaryOptions'=>['class'=>'text-right text-warning'],
                'width'=>'100px',
            ],
            [
                'attribute'=>'createtime',
                'format' => ['date','php:Y-m-d H:i:s'],
                'pageSummaryOptions'=>['class'=>'text-right text-warning'],
                'width'=>'100px',
            ],
            [
                'attribute'=>'createtime',
                'format' => ['date','php:Y-m-d H:i:s'],
                'pageSummaryOptions'=>['class'=>'text-right text-warning'],
                'width'=>'100px',
            ],
            [
                'attribute'=>'status',
                'width'=>'60px',
                'format' => 'raw',
                'value'=>function ($model, $key, $index, $widget) {
                    if($model->status==BusinessContractStatements::STATUS_DEFAULT){
                        return Html::label(BusinessContractStatements::$statues[$model->status], '', ['class' => 'btn btn-xs btn-default']);
                    }else if($model->status==BusinessContractStatements::STATUS_AGREE){
                        return Html::label('已审核', '', ['class' => 'btn btn-xs btn-success']);
                    }else if($model->status==BusinessContractStatements::STATUS_FINISH){
                        return Html::label('已结算', '', ['class' => 'btn btn-xs btn-primary']);
                    }

                    return Html::label(BusinessContractStatements::$statues[$model->status], '', ['class' => 'btn btn-xs btn-default']);
                },
                'filterType'=>GridView::FILTER_SELECT2,
                'filter'=> BusinessContractStatements::$statues,
                'filterWidgetOptions'=>[
                    'pluginOptions'=>['allowClear'=>true],
                ],
                'filterInputOptions'=>['placeholder'=>'选择状态']
            ],
            [
                'width'=>'160px',
                'class' => '\kartik\grid\ActionColumn',
                'template' => '{view} {update} {delete} {agree}',
                'buttons' => [
                    'agree' => function ($url, $model) {
                        return Html::a('审核通过','/business/contract-statements/agree?id='.$model->id,[
                            'title' => '审核通过','class'=>'purchase','data-id'=>$model->id,
                        ]);
                    }
                ],
            ],

        ],
        'toolbar'=> [
            '{export}',
            '{toggleData}',
        ],
        'bordered'=>true,
        'condensed'=>true,
    ]);
    ?>

</div>
</div>
</div>
</section>
</section>





